﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using SFP;
using SFP.Animation2D;

namespace HamsterDelivery
{
    public class Intro
    {
        public const int INTRO_TIME = 4000;

        private HamsterGame game;
        private double introTimePassed = 0;

        public Intro(HamsterGame game)
        {
            this.game = game;
        }

        public void update(double time)
        {
            introTimePassed += time;

            if (introTimePassed <= HamsterGame.FADE_TIME)
            {
                game.Fader.FadeAmount = 1 - introTimePassed / HamsterGame.FADE_TIME;
            }

            if (introTimePassed >= INTRO_TIME - HamsterGame.FADE_TIME)
            {
                game.Fader.FadeAmount = (introTimePassed - (INTRO_TIME - HamsterGame.FADE_TIME)) / HamsterGame.FADE_TIME;
            }

            if (introTimePassed >= INTRO_TIME)
            {
                introTimePassed = 0;
                game.InIntro = false;
                game.InMenu = true;
                game.Fader.startFading(Fader.FADE_IN);
            }
        }

        public void draw(Graphics g)
        {
            g.DrawImage(Resources.B_ULTRA_GAME_STUDIO, new Point(0, 0));
        }
    }
}
